@use '@scss/common' as *;
@use '../shared.scss';

.select {
  position: relative;
}

.reactSelect {
  display: flex;

  &:not(.isSearchable) {
    cursor: pointer;
  }

  :global {
    div.rs__control {
      @include shared.formInput;
    }

    .rs__control {
      line-height: 1;
      display: flex !important;
      align-items: center !important;

      &--is-disabled {
        cursor: not-allowed;

        :global {
          .rs__single-value {
            color: var(--theme-elevation-400);
          }

          .rs__indicators {
            display: none;
          }
        }
      }
    }

    .rs__input-container {
      color: var(--theme-text);
    }

    .rs__value-container {
      padding: 0;

      > * {
        margin-top: 0;
        margin-bottom: 0;
        padding-top: 0;
        padding-bottom: 0;
      }

      @include small-break {
        flex-direction: row;
        align-items: flex-start;
      }
    }

    .rs__single-value {
      color: var(--color-text);
    }

    .rs__indicators {
      position: absolute;
      top: 50%;
      right: 1rem;
      transform: translate3d(0, -50%, 0);

      .arrow {
        transform: rotate(90deg);
      }

      @include small-break {
        flex-direction: row;
        align-items: center;
      }
    }

    .rs__indicator {
      padding: 0px 4px;

      svg path {
        fill: var(--theme-elevation-700);
      }

      &:hover {
        svg path {
          fill: var(--theme-elevation-700);
        }
      }
    }

    .rs__indicator-separator {
      display: none;
    }

    .rs__menu {
      color: var(--theme-text);
      background-color: var(--theme-elevation-0);
      z-index: 2;
      border-radius: 0;
      box-shadow: 0 4px 11px hsl(0deg 0% 0% / 10%);
    }

    .rs__menu-list {
      padding: 0.25rem 0;
      border: 1px solid var(--theme-border-color);
    }

    .rs__group-heading {
      margin-bottom: 0.5rem;
    }

    .rs__option {
      font-size: 1rem;
      padding: 0.5rem 1rem;
      cursor: pointer;

      &--is-focused {
        background-color: var(--theme-elevation-100);
        color: var(--theme-text);
      }

      &--is-selected {
        background-color: var(--theme-elevation-200);
        color: var(--theme-text);
      }
    }

    .rs__multi-value {
      padding: 0;
      background: var(--theme-elevation-200);

      @include small-break {
        flex-direction: row;
        align-items: center;
      }
    }

    .rs__multi-value__label {
      max-width: 150px;
      color: var(--theme-text);
      padding: 0.125rem 0.25rem;
    }

    .rs__multi-value__remove {
      cursor: pointer;

      &:hover {
        color: var(--theme-text);
        background: var(--theme-elevation-100);
      }
    }

    .rs__clear-indicator {
      cursor: pointer;
    }
  }
}

:global([data-theme='dark']) {
  .select {
    .reactSelect {
      :global {
        .rs__menu {
          background-color: var(--theme-elevation-50);
        }
      }
    }
  }
}

:global([data-theme='light']) {
  .select {
    .reactSelect {
      :global {
        div.rs__control {
          background: var(--theme-elevation-0);
        }
      }
    }
  }
}

.description {
  @include small;
  & {
    margin-top: 0.5rem;
    color: var(--theme-elevation-400);
  }
}
